<template>
  <div>
    <!-- 大客户订单提报 -->
    <TopFilter
      :list="topFilterList"
      :cols="3"
      @filterChange="changeHandle"
      @onCollapse="collapseHandle"
      :labelWidth="110"
    ></TopFilter>

    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      columnsRef="zjOrderInquirys"
      :onRowSelectChange="selectChangeHandle"
      :onColumnsChange="columns => this.columns = columns"
    >
      <template slot="controls" slot-scope="props">
      </template>
    </FilterTable>

    <BaseDialog
      :visible.sync="isowner"
      :title="'选择经销商'"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <ownerSeacher :rowData="formData" @close="emitcloseHandler" />
    </BaseDialog>
    <BaseDialog
      :visible.sync="iscontract"
      :title="'选择合同'"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <contract :rowData="formData" @close="emitcloseHandler" />
    </BaseDialog>
    <BaseDialog
      :visible.sync="isProject"
      :title="'选择项目'"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <AccountProject :rowData="formData" @close="emitcloseHandler" />
    </BaseDialog>

    <Drawer
      :visible.sync="detailVisible"
      :title="'大客户订单信息'"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
      width="72%"
    >
      <detailModel  :rowData="formData" @close="emitcloseHandler" />
    </Drawer>

  </div>
</template>
<script>
import detailModel from './detailModel'
import AccountProject from './AccountProject'
import contract from './contract'
import ownerSeacher from './ownerSeacher'
export default {
  name:'TemplateDistribution',
  data(){
    this.BaseTable=null;
    return{
      topFilterList:this.createdFrom(),
      columns:this.createdTable(),
      fetchParams:{

      },
      fetchApi:()=>{},
      formData:{},
      detailVisible:false,
      iscontract:false,
      isProject:false,
      isDiscount:false,
      isowner:false,
    }
  },
  components: {
    ownerSeacher,
    detailModel,
    AccountProject,contract
  },
  mounted(){
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  created(){

  },
  methods:{
    createdFrom(){
      return [
        {
          type: 'INPUT',
          label: '选择经销商',
          fieldName: 'xzjxs',
          placeholder: '请选择',
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun(1)}></el-button>
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '合同名称',
          fieldName: 'htmc',
          placeholder: '请选择',
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun(2)}></el-button>
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '大客户项目名称',
          fieldName: 'dkhxmmc',
          placeholder: '请选择',
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun(3)}></el-button>
              </div>
            );
          }
        },

        {
          type: 'SELECT',
          label: '订单类型',
          fieldName: 'ddlx',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'SELECT',
          label: '订单类型细分',
          fieldName: 'ddlxxf',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'SELECT',
          label: '大客户名称',
          fieldName: 'dkhmc',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'SELECT',
          label: '订单状态',
          fieldName: 'ddzt',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'INPUT',
          label: '订单编号',
          fieldName: 'ddbh',
          placeholder: '请选择',
        },
        {
          type: 'RANGE_DATE',
          label: '提交日期',
          fieldName: 'tjrq',
          placeholder: '请选择',
          initialValue:[]
        },
        {
          type: 'SELECT',
          label: '车系名称',
          fieldName: 'cxmc',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'SELECT',
          label: '车型名称',
          fieldName: 'cxmc2',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'RANGE_DATE',
          label: '审核日期',
          fieldName: 'shrq',
          placeholder: '请选择',
          initialValue:[]
        },
        {
          type: 'SELECT',
          label: '配置名称',
          fieldName: 'pzmc',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'SELECT',
          label: '选装名称',
          fieldName: 'xzmc',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'SELECT',
          label: '内饰',
          fieldName: 'ns',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'SELECT',
          label: '外饰',
          fieldName: 'ws',
          placeholder: '请选择',
          itemList:[]
        },
      ]
    },
    createdTable(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 50,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <multiuse-button  size="mini" type="text" onClick={() => this.editHandle(props.row)}>
                  详情
                </multiuse-button>
              </div>
            );
          }
        },
        {
          title: '合同名称',
          dataIndex: 'jxsdm',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '大客户项目名称',
          dataIndex: 'jxsmc',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '大客户名称',
          dataIndex: 'htmc',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '经销商名称',
          dataIndex: 'dkhxmmc',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '订单编号',
          dataIndex: 'dkhmc',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '订单类型',
          dataIndex: 'ddlx',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '订单细分类型',
          dataIndex: 'ddxflx',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '订单状态',
          dataIndex: 'ddzt',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '资金类型',
          dataIndex: 'zjlx',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '运输方式',
          dataIndex: 'ysfs',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '提报数量',
          dataIndex: 'tbsl',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '订单总金额',
          dataIndex: 'ddzje',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '审批数量',
          dataIndex: 'spsl',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '发运数量',
          dataIndex: 'fysl',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '提报时间',
          dataIndex: 'flsyzje',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '收车地址',
          dataIndex: 'scdz',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '备注',
          dataIndex: 'remark',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '创建人',
          dataIndex: 'cjr',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '创建日期',
          dataIndex: 'cjrq',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
      ]
    },
    selectChangeHandle(row){

    },
    seacherFun(){
      this.issearch=true;
    },
    addHandle(data){
      this.detailVisible=true
    },
    changeHandle(params){
      this.fetchParams=Object.assign({},this.fetchParams,params)
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },
    async editHandle(data){
        this.detailVisible=true;

    },
    selectChangeHandle(val){

    },
    emitcloseHandler(){
      this.visible=false
      this.fetchParams=Object.assign({},this.fetchParams,params)
    }
  }
}
</script>
